package test_005;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;

public class TestCutMp4 {

	/**
	 * @param args
	 * @throws FileNotFoundException 
	 */
	public static void main(String[] args) throws FileNotFoundException {
			fileCopy("c://test.mp4","c://test1.jpeg");
	}
	public static void fileCopy(String primaryFile, String desFile) {
		File file = new File(primaryFile);
		if (file.exists()) {
			InputStream is = null;
			int len = -1;
			FileOutputStream out = null;
			byte[] bytes = new byte[1024];
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			if (file.canRead()) {
				try {
					is = new FileInputStream(primaryFile);
					while ((len = is.read(bytes)) != -1) {
						baos.write(bytes, 0, len);
					}
					out = new FileOutputStream(desFile);
					out.write(baos.toByteArray());
					out.flush();
				} catch (Exception e) {
					e.printStackTrace();
				} finally {
					try {
						if (baos != null) {
							baos.close();
						}
						if (is != null) {
							is.close();
						}
						if (out != null) {
							out.close();
						}
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}
		}
	}

}
